version 1.0

workflow fastq_to_fasta {
    input {
        File fastq_gz_file
        String output_basename
    }

    call GzipFastqToFasta {
        input:
            fastq_gz_file = fastq_gz_file,
            output_basename = output_basename
    }

    output {
        File fasta_file = GzipFastqToFasta.fasta_file
    }
}

task GzipFastqToFasta {
    input {
        File fastq_gz_file
        String output_basename
    }

    # use <<< >>> instead of {}
    # https://github.com/openwdl/wdl/blob/main/versions/1.0/SPEC.md#command-section
    command <<<
        gzip -dc ~{fastq_gz_file} | awk '{if((NR-1)%4 < 2){print $1}}' |sed "s/^\@/\>/" > ~{output_basename}.fasta
    >>>

    output {
        File fasta_file = "~{output_basename}.fasta"
    }

    runtime {
        cpu: 1
        memory: "1 GB"
    }
}
